/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ttaclient;

import Helper.TTAHelper.Helper_IPCluster;
import java.util.List;
import java.util.Scanner;
import javax.ejb.EJB;
import session.TX.ItineraryPlannerSBRemote;

/**
 *
 * @author Lu Xiaodi
 */
public class Main {

    @EJB
    public static ItineraryPlannerSBRemote itineraryPlannerBean;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int selection = 10;

        while (selection != 0) {

            System.out.println("Select options:");
            System.out.println("1. Add new user");
            System.out.println("2. Displays all users");
            System.out.println("3. Display user countryIdx and ageIdx");
            System.out.println("4. Add 20 new data models");
            System.out.println("5. Remove 20 new data models");
            System.out.println("6. Print out all data model clusters for a user");
            System.out.println("7. Populate 20 data model clusters for a user");
            System.out.println("8. Get the top 50 most popular stores");
            System.out.println("0. Exit");

            selection = sc.nextInt();
            sc.nextLine();
            if (selection == 1) {
                System.out.print("enter user email: ");
                String email = sc.nextLine();
                System.out.print("enter country: ");
                String country = sc.nextLine();
                System.out.print("enter birth year: ");
                int year = sc.nextInt();
                itineraryPlannerBean.createUser_Test(email, country, year);
            } else if (selection == 2) {
                List<String> users = itineraryPlannerBean.printUser_Test();
                System.out.println();
                System.out.println("================Display all users===============");
                for (String u : users) {
                    System.out.println(u);
                }
                System.out.println("============End displaying all users============");
                System.out.println();
            } else if (selection == 3){
                System.out.print("enter user Id: ");
                String uIdStr = sc.nextLine();
                Long uId = Long.parseLong(uIdStr);
                List<Integer> result = itineraryPlannerBean.getCountryAgeIdx(uId);
                System.out.println("CountryIdx:" + result.get(0));
                System.out.println("Age:" + result.get(1));
                System.out.println("AgeIdx:" + result.get(2));
            } else if (selection == 4) {
                for (int i = 0; i < 20; i++) {
                    Long outletId = new Long(100000 + i);
                    itineraryPlannerBean.addNewOutletDataModel_Test(outletId);
                }
            } else if (selection == 5) {
                itineraryPlannerBean.removeNewOutletDataModel_Test();
            } else if (selection == 6) {
                System.out.print("enter user email: ");
                String email = sc.nextLine();
                List<String> result = itineraryPlannerBean.printDataModelByUser(email);
                System.out.println("================Display all datamodels===============");
                for (int i = 0 ; i < result.size(); i++){
                    System.out.println(result.get(i));
                }
                System.out.println("============End displaying all datamodels============");
            } else if (selection == 7) {
                System.out.print("enter user email: ");
                String email = sc.nextLine();
                itineraryPlannerBean.updateOutletDataModel_Test(email);
            } else if (selection == 8) {
                System.out.print("enter user Id: ");
                String uIdStr = sc.nextLine();
                Long uId = Long.parseLong(uIdStr);
                List<Helper_IPCluster> result = itineraryPlannerBean.recommendOutletId(uId);
                System.out.println("================Display top 50 outlets===============");
                for (int i = 0 ; i < result.size(); i++){
                    System.out.println("OutletId:" + result.get(i).getOutletId() +"; Popularity:" +
                            result.get(i).getPopularity());
                }
                System.out.println("============End displaying top 50 outlets============");
            }
        }
    }
}
